package com.burpee.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.burpee.ui.Healthpoint;

@Repository(value="healthpointDao")
public class HealthpointDaoImpl implements HealthpointDao {

	SqlSessionTemplate sqlSessionTemplate;

	@Autowired
	public void setSqlSessionTemplate(SqlSessionFactory sqlSessionFactory ) {
		this.sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
	}

	public List<Healthpoint> list(String memberId) {
		List<Healthpoint> list = null;

		try {
			list = sqlSessionTemplate.selectList("healthpointlist",memberId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return list;

	}

	public Healthpoint view(String memberId) {
		Healthpoint healthpoint = new Healthpoint();

		try {
			healthpoint = sqlSessionTemplate.selectOne("healthpointview", memberId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return healthpoint;
	}

	public int add(Healthpoint healthpoint) {
		int result = 0;

		try {
			result = (int)sqlSessionTemplate.insert("healthpointadd",healthpoint);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return result;
	}

}
